package com.mlyol.singleton;

public class Demo4 {

    public static void main(String[] args) {
        Demo4 instance1 = Demo4.getInstance();
        Demo4 instance2 = Demo4.getInstance();
        System.out.println(instance1==instance2);
    }

    private Demo4() {

    }

    private static Demo4 instance;

    public static synchronized Demo4 getInstance() {
        if (instance == null) {
            instance = new Demo4();
        }
        return instance;
    }


}
